package com.cxh.rmsq.ui.activity.self

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import com.blankj.utilcode.util.BarUtils
import com.blankj.utilcode.util.ColorUtils
import com.cxh.rmsq.R
import com.cxh.rmsq.databinding.ActivityLoginPcBinding
import com.cxh.rmsq.net.newNet.TreasureViewModel
import com.cxh.rmsq.utils.ToastUtils
import io.rong.callkit.util.SPUtils

class LoginPcActivity : AppCompatActivity() {
    private lateinit var binding: ActivityLoginPcBinding
    private val viewModel by lazy {
        ViewModelProvider.NewInstanceFactory().create(TreasureViewModel::class.java)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityLoginPcBinding.inflate(layoutInflater)
        setContentView(binding.root)
        binding.clToolbar.setPadding(0, BarUtils.getStatusBarHeight(), 0, 0)
//        findViewById<ConstraintLayout>(R.id.cl_toolbar).setPadding(0, BarUtils.getStatusBarHeight(), 0, 0)
        BarUtils.setStatusBarColor(this, ColorUtils.getColor(R.color.color_F5F5F5))
        BarUtils.setStatusBarLightMode(this, true)

        binding.ivBack.setOnClickListener {
            finish()
        }
        binding.tvCancleLogin.setOnClickListener {
            finish()
        }
        binding.stvLogin.setOnClickListener {
            val map = HashMap<String, Any>()
            map["mobile"] = SPUtils.get(this, "loginMob", "")
            map["qrCode"] = intent.getStringExtra("qrCode").toString()
            viewModel.qrCodeLogin(map) {
                if (it.code == 200) {
                    ToastUtils.showToast("授权登录成功")
                    finish()
                } else {
                    ToastUtils.showToast(it.msg)
                }
            }
        }
    }
}